﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace DAL
{
    public class db
    {
        

        public static DataSet ExecuteSP(string spName, params SqlParameter[] sqlParams)
        {
            DataSet ds = new DataSet();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["main"].ToString()))
            {
                SqlCommand sqlComm = new SqlCommand(spName, conn);
                sqlComm.Parameters.AddRange(sqlParams);
                sqlComm.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = sqlComm;

                da.Fill(ds);
            }

            return ds;
        }
    }
}
